package com.work.service.bd.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.work.entity.bd.BdTeam;
import com.work.mapper.bd.BdTeamMapper;
import com.work.service.bd.IBdTeamService;
import com.work.vo.bd.BdTeamTreeVO;
import com.work.wrapper.bd.BdTeamTreePCWrapper;
import com.work.wrapper.bd.BdTeamTreeWrapper;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 队组接口实现
 *
 * @author ：dujianyu
 * @since ：Created in 2024/5/20 8:59
 */
@Service
public class BdTeamServiceImpl extends BaseServiceImpl<BdTeamMapper, BdTeam> implements IBdTeamService {
    @Override
    public List<BdTeamTreeVO> selectBdTeamTree() {
        return BdTeamTreeWrapper.build().listNodeVO(getData());
    }

    @Override
    public List<BdTeamTreeVO> selectBdTeamTreePc() {
        return BdTeamTreePCWrapper.build().listNodeVO(getData());
    }

    private List<BdTeam> getData() {
        QueryWrapper<BdTeam> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().select(BdTeam::getId, BdTeam::getName, BdTeam::getSort, BdTeam::getParentId, BdTeam::getTransportCorpId)
                .eq(BdTeam::getIsDeleted, 0).orderByAsc(BdTeam::getSort);
       return baseMapper.selectList(queryWrapper);
    }
}
